#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool isPalindrome(string s) {
        int begin = 0;
        int end = s.size() - 1;
        while (begin < end)
        {
            while (begin < end && !isalnum(s[begin]))
            {
                begin++;
            }
            while (begin < end && !isalnum(s[end]))
            {
                end--;
            }
            if (tolower(s[begin]) != tolower(s[end]))
            {
                return false;
            }
            begin++;
            end--;
        }
        return true;
    }
};